import request from "@/utils/requests/index";
import { RequestEnum } from '@/enums/httpEnum'
import { Response } from '@/api/types/index'
import { MenuMould } from './types/index'

enum Api {
  // 获取菜单树形结构列表
  GET_MENU_LIST_PATH = '/admin/menu/list',
  // 新增、编辑、删除菜单
  CRUD_MENU_PATH = 'admin/menu'
}

export function getMenuListReq() {
  return request.request({
    method: RequestEnum.GET,
    url: Api.GET_MENU_LIST_PATH,
  })
}

// 新增
export function addMenuReq(data: MenuMould.IMenuItem) {
  return request.request({
    method: RequestEnum.POST,
    url: Api.CRUD_MENU_PATH,
    data
  })
}

// 编辑
export function editMenuReq(data: MenuMould.IMenuItem) {
  return request.request({
    method: RequestEnum.PUT,
    url: Api.CRUD_MENU_PATH,
    data
  })
}

// 删除
export function deleteMenuReq(id: number | string) {
  return request.request({
    method: RequestEnum.DELETE,
    url: Api.CRUD_MENU_PATH + `/${id}`
  })
}